from appium.webdriver.common.appiumby import AppiumBy
from App.base_page import BasePage


class ZsxjPage(BasePage):

    __BUTTON_SEARCH = (AppiumBy.ID, "com.xueqiu.android:id/search_edittext")
    __INPUT_SEARCH = (AppiumBy.ID, "com.xueqiu.android:id/search_edittext")
    __BUTTON_LISTFIRST = (AppiumBy.XPATH, "//*[@text='指数']/following::*[1]/child::*[1]")
    __BUTTON_QUIT = (AppiumBy.XPATH, "/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget"
                                     ".LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android"
                                     ".widget.FrameLayout/android.widget.RelativeLayout/android.widget"
                                     ".RelativeLayout[1]/android.widget.FrameLayout/android.widget.LinearLayout["
                                     "1]/android.widget.ImageView")
    __BUTTON_CLEAR = (AppiumBy.ID, "com.xueqiu.android:id/search_clear")
    __BUTTON_CANCEL = (AppiumBy.XPATH, "//*[@text='取消']")

    __BUTTON_ZT = (AppiumBy.XPATH, "//*[@text='主题']")
    __BUTTON_SELECTLIST = (AppiumBy.ID, "com.xueqiu.android:id/to_setting")
    __BUTTON_HB = (AppiumBy.XPATH, "//*[@text='环保']")



    def click_serach(self,):
        self.do_click(self.__BUTTON_SEARCH)

    def send_serach(self, keyword):
        self.do_send_keys(self.__INPUT_SEARCH, keyword)

    def click_listfirst(self,):
        self.do_click(self.__BUTTON_LISTFIRST)

    def click_quit(self,):
        self.do_click(self.__BUTTON_QUIT)

    def click_clear(self,):
        self.do_click(self.__BUTTON_CLEAR)

    def click_cancel(self,):
        self.do_click(self.__BUTTON_CANCEL)

    def click_zt(self):
        self.do_click(self.__BUTTON_ZT)

    def click_selectlist(self):
        self.do_click(self.__BUTTON_SELECTLIST)

    def click_hb(self):
        self.do_click(self.__BUTTON_HB)



